<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0px;
            margin: 0px;
        }

        #app {
            width: 100%;
            margin: 0 auto;
            background-color: rgb(97, 201, 168);
            height: 800px;
        }

        .todo-input {
            background-color: rgb(47, 38, 31);
            height: 50px;
            display: flex;
            padding-left: 25%;
        }

        .todo-input__left {
            width: 200px;
            height: 50px;
            font-size: 40px;
            line-height: 50px;
            color: #fff;

        }

        .todo-input__right {
            width: 400px;
            height: 50px;
            display: flex;
            padding-top: 12px;
            padding-left: 30px;
            box-sizing: border-box;
        }

        .input-right {
            width: 250px;
            height: 25px;
            outline: none;
            border-radius: 4px;
            border: 0px;
            padding-left: 4px;
        }

        .button-right {
            width: 50px;
            height: 25px;
            margin-left: 5px;
            border-radius: 3px;
            border: 0px;
            cursor: pointer;
        }

        .box1,
        .box2 {
            margin-left: 25%;
            margin-right: 90px;
        }

        .font {
            display: flex;
            padding: 4px 0;
            justify-content: space-between;
        }

        .title {
            width: 20px;
            height: 20px;
            background-color: #fff;
            border-radius: 50%;
            text-align: center;
            color: #333;
        }

        .todo-item {
            width: 570px;
            height: 32px;
            background-color: white;
            margin-bottom: 5px;
            border-radius: 4px;
            display: flex;
            padding: 4px 20px;
            box-sizing: border-box;
            justify-content: space-between;
            align-items: center;
            border-left: 4px solid pink;
        }

        .todo-item__left {
            display: flex;

        }

        .todo-item__text {
            margin-left: 5px;
        }

        .active {
            opacity: .5;
            border-left: 4px solid black;
        }
    </style>
</head>

<body>
    <div id="app">
        <todo-input @change="add($event)"></todo-input>
        <div class="box1">
            <div class="font">
                <h3>正在进行</h3>
                <div class="title">1</div>
            </div>
            <todo-item></todo-item>
        </div>
        <div class="box2">
            <div class="font">
                <h3>已经完成</h3>
                <div class="title">1</div>
            </div>
            <todo-item class="active"></todo-item>
        </div>

    </div>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.9/vue.js"></script>
    <script>
        
        Vue.component("TodoInput", {
            name: "TodoInput",
            template: `<div class="todo-input">
                    <div class="todo-input__left">toDoList</div>
                    <div class="todo-input__right">
                        <div><input class="input-right" type="text" v-model="value"></div>
                        <div><button class="button-right" @click="add">添加</button></div>    
                    </div>
                </div>`,

            props: {
                value:{
                    type: String,
                }
        
            },
            methods:{
                add(){
                    console.log(this.value);
                    this.$emit("change",this.value);
                    // this.$emit("change",$event.target.value)
                }
            }
            

        })

        
        Vue.component("TodoItem", {
            name: "TodoItem",
            template: `<div class="todo-item">
                    <div class="todo-item__left">
                        <div><input type="checkbox" ></div>
                        <div class="todo-item__text">学习</div>
                    </div>
                    <button>
                        删除
                    </button>
                </div>`
        })

       var todolist = [{title:"吃饭",done: false,},
                      {title:"睡觉",done: true}];
                    //   {title:"睡觉",done: true,del:true,id:2}];


        var vm = new Vue({
            el: '#app',
            data: {
               todolist,
            },
            methods:{
                add(event){
                    this.$set(this.todolist,todolist.length,event);
                    
                }
            }
        })
    </script>
</body>

</html>